package com.my.chapter13;

import java.io.PrintStream;
import java.util.Formatter;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Test {
    public static void main(String[] args) {
        String s = "You are fighter.";
        String regex = "f.*\\.";
        Pattern p = Pattern.compile(regex);
        Matcher m = p.matcher(s);
        while(m.find()){
            System.out.println("Match \"" + m.group() + "\" at positions " + m.start() + "-" + (m.end()-1));
        }
    }
}

/*Output：
Match "fighter." at positions 8-15
*/


